package com.guestmanage.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.guestmanage.bean.RdgionYu2;
import com.guestmanage.bean.SpRecvLis;
import com.guestmanage.service.SpRecvLisService;
import com.guestmanage.servlet.util.BaseAction;
import com.guestmanage.servlet.util.SpNameCode;
/**
 * 上行监控 doGET 删除，doPost 添加
 * @author Jenno.song
 *2011-03-28
 */
public class SpRecvLisDel extends HttpServlet{

	private static final long serialVersionUID = -3368165012855674679L;
	
	private SpRecvLisService splSer=SpRecvLisService.getInsetance();
	
	public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
		BaseAction base=new BaseAction(request,response);
		
		int id=base.getParameterInt("id");
		
		splSer.delete(id);
		
		base.forward("/SpRecvLisServlet");
	}
	
	public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
		BaseAction base=new BaseAction(request,response);
		
		String city=(String)base.getSessionAttribute("city");
		
		String spCode=base.getParameterString("spCode");
		int recvCount=base.getParameterInt("recvCount");
		int hourNum=base.getParameterInt("hourNum");
		
		RdgionYu2 rd2=splSer.findByCity(city);
		SpNameCode spnamecode=new SpNameCode();
		
		String[] str=spnamecode.equalsCode(new String[]{spCode});
		
		SpRecvLis srl=new SpRecvLis();
		srl.setCityId(rd2.getTeleid());
		srl.setCityName(city);
		srl.setHourNum(hourNum);
		srl.setRecvCount(recvCount);
		srl.setSpNameCode(spCode);
		srl.setSpName(str[0]);
		
		boolean oo=splSer.save(srl);
		base.printWriter(oo+"");
	}

}
